Page({
  data: {
    notstarted: {
      status: 0,
      statusDesc: '课程已过期',
      desc: '您的课程由于长时间未确认，已经过期。如有疑问，请联系管理员',
      src: '/images/detail/weikaishi@2x.png',
      msg: '课程已过期了哟~'
    },
    complete: {
      status: 1,
      statusDesc: '已结课',
      src: '/images/detail/yijieke@2x.png',
      msg: '赞！！！该门课程你已经完成啦~'
    },
    clickedNotStarted: {
      status: 2,
      statusDesc: '课程还未开始',
      desc: '当你完成上一阶段的课程时，当前课程才会开启哦',
      src: '/images/detail/weikaishi@2x.png',
      msg: '课程还未开始哦~'
    },
    lesson: {}
  },
  onLoad(options) {
    // console.log('options')
    // console.log(options)
    let { coursename, status } = options
    let lessonStatus = {
      desc: `恭喜你，完成了《${coursename}》的课程，再接再厉哦！`,
      coursename: coursename
    }

    switch (status) {
      case "0":
        Object.assign(lessonStatus, this.data.notstarted)
        wx.setNavigationBarTitle({
          title: '已过期'
        })
        break;
      case "2":
        Object.assign(lessonStatus, this.data.clickedNotStarted)
        wx.setNavigationBarTitle({
          title: '未开始'
        })
        break;
      case "7":
        if (wx.getStorageSync('sevenData')){
          lessonStatus = {
            desc: `恭喜你，完成了《${wx.getStorageSync('sevenData').coursename}》的课程，再接再厉哦！`,
            coursename: coursename
          }
        }
        
        Object.assign(lessonStatus, this.data.complete)
        wx.setNavigationBarTitle({
          title: '已结课'
        })
        break;
    }
    this.setData({
      lesson: lessonStatus
    })
  }
})